package org.example.io;

import java.io.InputStream;
import java.net.ServerSocket;
import java.net.Socket;

public class IOServer {
    public static void main(String[] args) throws Exception{
        ServerSocket serverSocket = new ServerSocket(8000);

        while (true) {
            Socket socket = serverSocket.accept();
            new Thread(() -> {
                try {
                    byte[] buff = new byte[1024];
                    InputStream inputStream = socket.getInputStream();
                    int len = 0;
                    while ((len = inputStream.read(buff)) > 0) {
                        System.out.println(new String(buff, 0, len));
                    }
                } catch (Exception e) {
                    throw new RuntimeException(e);
                }
            }).start();
        }
    }
}
